export function _debounce(fn, delay) {
    var delay = delay || 200;
    let timer;
    return function () {
        const self = this;
        const args = arguments;
        if (timer) {
            clearTimeout(timer);
        }
        timer = setTimeout(function () {
            timer = null;
            fn.apply(self, args);
        }, delay);
    };
}

export function _throttle(fn, interval) {
    var last;
    var timer;
    var interval = interval || 2000;
    return function () {
        var self = this;
        var args = arguments;
        var now = +new Date();
        if (last && now - last < interval) {
            clearTimeout(timer);
            timer = setTimeout(function () {
                last = now;
            }, interval);
        } else {
            last = now;
            fn.apply(self, args);
        }
    };
}
